package com.sqx.modules.ruleClassify.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.ruleClassify.entity.RuleClassify;
import com.sqx.modules.ruleClassify.service.RuleClassifyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "机械管理", tags = {"机械管理"})
@RequestMapping(value = "/admin/rule/")
public class RuleController {

    @Autowired
    private RuleClassifyService ruleClassifyService;

    @ApiOperation("添加机械")
    @PostMapping("addClassify")
    public Result addClassify(RuleClassify ruleClassify) {
        return ruleClassifyService.addClassify(ruleClassify);
    }

    @ApiOperation("管理员获取一级机械列表")
    @GetMapping("adminGetClassifyList")
    public Result adminGetClassifyList(Integer page, Integer limit, RuleClassify classify) {
        return Result.success().put("data", ruleClassifyService.adminGetClassifyList(page, limit, classify));
    }

    @ApiOperation("管理员根据一级分类获取下级分类")
    @GetMapping("adminGetParentId")
    public Result adminGetParentId(Integer page, Integer limit, RuleClassify classify) {
        return Result.success().put("data", ruleClassifyService.adminGetParentId(page, limit, classify));
    }

    @ApiOperation("修改机械")
    @PostMapping("updateClassify")
    public Result updateClassify(RuleClassify ruleClassify) {
        return ruleClassifyService.updateClassify(ruleClassify);
    }

    @ApiOperation("删除机械")
    @GetMapping("deleteClassify")
    public Result deleteClassify(Long ruleClassifyId) {
        return ruleClassifyService.deleteClassify(ruleClassifyId);
    }


}
